using System.Diagnostics;
namespace MultiAgentsShared;

public class Time
{
    private static readonly Stopwatch stopwatch = Stopwatch.StartNew();

    private static double lastUpdateTime = TimeInMS;
    private static double lastDeltaTime = 0;

    public static double TimeInS
    {
        get
        {
            return stopwatch.Elapsed.TotalSeconds;
        }
    }

    public static double TimeInMS
    {
        get
        {
            return stopwatch.Elapsed.TotalMilliseconds;
        }
    }

    public static double DeltaTime => lastDeltaTime;

    public static void UpdateTime()
    {
        var now = TimeInMS;
        lastDeltaTime = (now - lastUpdateTime);
        lastUpdateTime = now;
    }
}
